﻿//JS for resizing panes

function sizeElement(e, heightOffset) {
    var w = 0;
    var h = 0;

    //IE
    if (!window.innerWidth) {
        //strict mode
        if (!(document.documentElement.clientWidth == 0)) {
            w = document.documentElement.clientWidth;
            h = document.documentElement.clientHeight;
        }
        //quirks mode
        else {
            w = document.body.clientWidth;
            h = document.body.clientHeight;
        }
    }
    //w3c
    else {
        w = window.innerWidth;
        h = window.innerHeight;
    }


    e = document.getElementById(e);
    var newH = h - heightOffset + "px";

    e.style.height = newH;
}

function fixGridView() {
   var gridPane = document.getElementById('gridPane');
   var resultsPane = document.getElementById('resultsPane');
   //not checking IE quirks mode as minHeight is anyway not supported in quirks	
   if(!window.innerHeight)
	   resultsPane.style.minHeight = document.documentElement.clientHeight * 0.7;		
   else
	resultsPane.style.minHeight = window.innerHeight * 0.7; 	
   var gridMinHeight = 0.5 * resultsPane.scrollHeight;
   //If scrollheight is more than 50% make sure the max height is controlled else height can be auto
   if (gridPane.scrollHeight >= gridMinHeight) {
       gridPane.style.maxHeight = gridMinHeight;

   }
}

function fixFormView() {
    //page height - nav header
    sizeElement('resultsPane', 110);
    //page height - nav header - results pane header
    sizeElement('inputForm', 196);
    sizeElement('navPane', 151);
    sizeElement('tasksPaneForm', 151);
}

function fixNavlessFormView() {
    //page height - nav header
    sizeElement('resultsPane', 110);
    //page height - nav header - results pane header
    sizeElement('inputForm', 196);
    sizeElement('tasksPaneForm', 151);
}

function fixWizardView() {
    //page height - nav header
    sizeElement('resultsPane', 110);
    //page height - nav header - results pane header
    sizeElement('inputForm', 237);
    sizeElement('navPane', 192);
    sizeElement('tasksPaneForm', 192);
}

function fixNavlessWizardView() {
    //page height - nav header
    sizeElement('resultsPane', 110);
    //page height - nav header - results pane header
    sizeElement('inputForm', 237);
    sizeElement('tasksPaneForm', 192);
}

 
